﻿using Architecture.CrossCutting.Common;
using Architecture.CrossCutting.Common.Dependency;
using Architecture.CrossCutting.Common.Logging;
using Architecture.CrossCutting.LoggingEntities.Logger;
using Architecture.CrossCutting.Web;
using Architecture.CrossCutting.Web.Tracing.Model;
using Architecture.CrossCutting.Web.WCF;
using Microsoft.Practices.Unity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace Architecture.Services.WCFServices
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            var container = new UnityContainer();
            //container.RegisterType<IGenericLogger<WcfLogDetail>, Logger<WcfLogDetail>>(new HierarchicalLifetimeManager());
            container.RegisterType<IGenericLogger<WcfClientLog>, WcfClientLogger>(new HierarchicalLifetimeManager());
            container.RegisterType<IGenericLogger<WcfServiceLog>, WcfServiceLogger>(new HierarchicalLifetimeManager());
            container.RegisterType<IGenericLogger<WebApiLog>, WebApiLogger>(new HierarchicalLifetimeManager());
            //container.RegisterType<IGenericLogger<WebApiLog>, StandardWebApiLogger>(new HierarchicalLifetimeManager());

            container.RegisterType<IExecutionContext, WcfCustomContext>();

            CustomContext.Current.DependencyResolver = new UnityResolver(container);

        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}